﻿#ifndef IOTTYPEDEF_H
#define IOTTYPEDEF_H
#include <QString>
#include <QMap>
#include <QJsonObject>

enum EDataType{
    Type_Int,
    Type_Float,
    Type_String,
    Type_Bool
};

enum EWindowType{
    MainWindow,
    ModelManage,
    EditModel,
    DeviceManage,
    EditDevice
};

static const QMap<EWindowType, QString> windowNameMap = {
    {EWindowType::MainWindow, "mianWindow"},
    {EWindowType::ModelManage, "modelManage"},
    {EWindowType::EditModel, "editModel"},
    {EWindowType::DeviceManage, "deviceManage"},
    {EWindowType::EditDevice, "editDevice"}
};

enum ESigType {
    ESigTypeUnDefine,
    EYx,
    EYc,
    EYk,
    EParameter
};

enum EOptType {
    EAdd,
    EDelete,
    EChange,
    ESelect,
    EOptUnDefine
};

static const QMap<bool, QString> boolToString = {
    {true,"true"},
    {false,"false"}
};

static const QMap<QString, bool> stringToBool = {
    {"true",true},
    {"false",false}
};

enum EUserType {
    EUserTypeRoot,
    EUserTypeUser,
    EUserTypeGuest
};


enum ECause{
    ETest,
    ECollect,
    EDemonstration
};

struct SRtDeviceInfo {
    QString user;
    QString model_name;
    QString name;
    QString descr;
    int sn;
    QString grouping;
    QDateTime create_time;
    QDateTime update_time;
    QString location;
    int protocol;
    bool valid;
};

struct SRtYxValue {
    QDateTime ts;
    QDateTime sts;
    int v;
    ECause cause;
};

struct SRtYcValue {
    QDateTime ts;
    QDateTime sts;
    float v;
    ECause cause;
    bool alarm;
    int alarm_count;
    int limit_time;
};

struct SRtYkValue {
    QDateTime ts;
    QDateTime sts;
    int v;
    ECause cause;
};

struct SRtParameterValue {
    QDateTime ts;
    QDateTime sts;
    float v;
    ECause cause;
};


#endif // IOTTYPEDEF_H
